package cn.home.fenni.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.home.common.annotation.Log;
import cn.home.common.core.controller.BaseController;
import cn.home.common.core.domain.AjaxResult;
import cn.home.common.enums.BusinessType;
import cn.home.fenni.domain.HomeServicePackagetag;
import cn.home.fenni.service.IHomeServicePackagetagService;
import cn.home.common.utils.poi.ExcelUtil;
import cn.home.common.core.page.TableDataInfo;

/**
 * 服务包-服务包标签Controller
 * 
 * @author gm
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/packagetag/packagetag")
public class HomeServicePackagetagController extends BaseController
{
    @Autowired
    private IHomeServicePackagetagService homeServicePackagetagService;

    /**
     * 查询服务包-服务包标签列表
     */
    @PreAuthorize("@ss.hasPermi('packagetag:packagetag:list')")
    @GetMapping("/list")
    public TableDataInfo list(HomeServicePackagetag homeServicePackagetag)
    {
        startPage();
        List<HomeServicePackagetag> list = homeServicePackagetagService.selectHomeServicePackagetagList(homeServicePackagetag);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('packagetag:packagetag:list')")
    @GetMapping("/list2")
    public TableDataInfo list2(HomeServicePackagetag homeServicePackagetag){
        startPage();
        List<HomeServicePackagetag> list = homeServicePackagetagService.selectHomeServicePackagetagByPackageId();
        return getDataTable(list);
    }
    /**
     * 导出服务包-服务包标签列表
     */
    @PreAuthorize("@ss.hasPermi('packagetag:packagetag:export')")
    @Log(title = "服务包-服务包标签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HomeServicePackagetag homeServicePackagetag)
    {
        List<HomeServicePackagetag> list = homeServicePackagetagService.selectHomeServicePackagetagList(homeServicePackagetag);
        ExcelUtil<HomeServicePackagetag> util = new ExcelUtil<HomeServicePackagetag>(HomeServicePackagetag.class);
        util.exportExcel(response, list, "服务包-服务包标签数据");
    }

    /**
     * 获取服务包-服务包标签详细信息
     */
    @PreAuthorize("@ss.hasPermi('packagetag:packagetag:query')")
    @GetMapping(value = "/{relationId}")
    public AjaxResult getInfo(@PathVariable("relationId") Long relationId)
    {
        return success(homeServicePackagetagService.selectHomeServicePackagetagByRelationId(relationId));
    }

    /**
     * 新增服务包-服务包标签
     */
    @PreAuthorize("@ss.hasPermi('packagetag:packagetag:add')")
    @Log(title = "服务包-服务包标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HomeServicePackagetag homeServicePackagetag)
    {
        return toAjax(homeServicePackagetagService.insertHomeServicePackagetag(homeServicePackagetag));
    }

    /**
     * 修改服务包-服务包标签
     */
    @PreAuthorize("@ss.hasPermi('packagetag:packagetag:edit')")
    @Log(title = "服务包-服务包标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HomeServicePackagetag homeServicePackagetag)
    {
        return toAjax(homeServicePackagetagService.updateHomeServicePackagetag(homeServicePackagetag));
    }

    /**
     * 删除服务包-服务包标签
     */
    @PreAuthorize("@ss.hasPermi('packagetag:packagetag:remove')")
    @Log(title = "服务包-服务包标签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{relationIds}")
    public AjaxResult remove(@PathVariable Long[] relationIds)
    {
        return toAjax(homeServicePackagetagService.deleteHomeServicePackagetagByRelationIds(relationIds));
    }
}
